home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fsutil / fsutilTrace.h < prev    next >
C/C++ Source or Header  |  1990-10-10  |  5KB  |  175 lines

  1. /*
  2.  * fsutilTrace.h --
  3.  *
  4.  *    Definitions for the filesystem trace record.  This includes the
  5.  *    trace record types, and externs for the trace record itself.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  */
  17.  
  18. #ifndef _FSTRACE
  19. #define _FSTRACE
  20.  
  21. #include <trace.h>
  22.  
  23. #define FSUTIL_TRACE_0        0
  24. #define FSUTIL_TRACE_OPEN_START    1
  25. #define FSUTIL_TRACE_LOOKUP_START    2
  26. #define FSUTIL_TRACE_LOOKUP_DONE    3
  27. #define FSUTIL_TRACE_DEL_LAST_WR    4
  28. #define FSUTIL_TRACE_OPEN_DONE    5
  29. #define FSUTIL_TRACE_BLOCK_WAIT    6
  30. #define FSUTIL_TRACE_BLOCK_HIT    7
  31. #define FSUTIL_TRACE_DELETE        8
  32. #define FSUTIL_TRACE_NO_BLOCK    9
  33. #define FSUTIL_TRACE_OPEN_DONE_2    10
  34. #define FSUTIL_TRACE_OPEN_DONE_3    11
  35. #define FSUTIL_TRACE_INSTALL_NEW    12
  36. #define FSUTIL_TRACE_INSTALL_HIT    13
  37. #define FSUTIL_TRACE_RELEASE_FREE    14
  38. #define FSUTIL_TRACE_RELEASE_LEAVE    15
  39. #define FSUTIL_TRACE_REMOVE_FREE    16
  40. #define FSUTIL_TRACE_REMOVE_LEAVE    17
  41. #define FSUTIL_TRACE_SRV_WRITE_1    18
  42. #define FSUTIL_TRACE_SRV_WRITE_2    19
  43. #define FSUTIL_TRACE_SRV_GET_ATTR_1    20
  44. #define FSUTIL_TRACE_SRV_GET_ATTR_2    21
  45. #define FSUTIL_TRACE_OPEN        22
  46. #define FSUTIL_TRACE_READ        23
  47. #define FSUTIL_TRACE_WRITE        24
  48. #define FSUTIL_TRACE_CLOSE        25
  49. #define    FSUTIL_TRACE_RA_SCHED    26
  50. #define    FSUTIL_TRACE_RA_BEGIN    27
  51. #define    FSUTIL_TRACE_RA_END        28
  52. #define FSUTIL_TRACE_DEL_BLOCK    29
  53. #define FSUTIL_TRACE_BLOCK_WRITE    30
  54. #define FSUTIL_TRACE_GET_NEXT_FREE    31
  55. #define FSUTIL_TRACE_LRU_FREE    32
  56. #define FSUTIL_TRACE_LRU_DONE_FREE    33
  57. #define FSUTIL_TRACE_34
  58. #define FSUTIL_TRACE_35
  59.  
  60. extern Trace_Header *fsutil_TraceHdrPtr;
  61. extern int fsutil_TraceLength;
  62. extern Boolean fsutil_Tracing;
  63. extern int fsutil_MaxTraceDataSize;
  64. extern int fscache_RATracing;
  65.  
  66. /*
  67.  * The following types and macros are used to take filesystem trace data.
  68.  * Each struct has to be smaller than a Fsutil_TraceRecord - see the call to
  69.  * Trace_Init in fsInit.c - as the trace module pre-allocates storage.
  70.  */
  71. typedef enum { FST_NIL, FST_IO, FST_NAME,
  72.         FST_HANDLE, FST_RA, FST_BLOCK } Fsutil_TraceRecType ;
  73.  
  74. typedef struct Fsutil_TraceIORec {
  75.     Fs_FileID    fileID;
  76.     int        offset;
  77.     int        numBytes;
  78. } Fsutil_TraceIORec;
  79.  
  80. typedef struct Fsutil_TraceHdrRec {
  81.     Fs_FileID    fileID;
  82.     int        refCount;
  83.     int        numBlocks;
  84. } Fsutil_TraceHdrRec;
  85.  
  86. typedef struct Fsutil_TraceBlockRec {
  87.     Fs_FileID    fileID;
  88.     int        blockNum;
  89.     int        flags;
  90. } Fsutil_TraceBlockRec;
  91.  
  92. typedef struct Fsutil_TraceRecord {
  93.     union {
  94.     Fs_FileID    fileID;
  95.     Fsutil_TraceHdrRec    hdrRec;
  96.     Fsutil_TraceIORec    ioRec;
  97.     Fsutil_TraceBlockRec    blockRec;
  98.     char        name[40];
  99.     } un;
  100. } Fsutil_TraceRecord;
  101.  
  102. extern int fsutil_TracedFile;
  103.  
  104. #ifndef CLEAN
  105.  
  106. #define FSUTIL_TRACE(event) \
  107.     if (fsutil_Tracing) {                        \
  108.     Trace_Insert(fsutil_TraceHdrPtr, event, (ClientData)NIL);    \
  109.     }
  110.  
  111. #define FSUTIL_TRACE_IO(event, zfileID, zoffset, znumBytes) \
  112.     if (fsutil_Tracing &&                        \
  113.     (fsutil_TracedFile < 0 || fsutil_TracedFile == zfileID.minor)) {    \
  114.     Fsutil_TraceIORec ioRec;                    \
  115.     ioRec.fileID = zfileID;                    \
  116.     ioRec.offset = zoffset;                    \
  117.     ioRec.numBytes = znumBytes;                \
  118.     Trace_Insert(fsutil_TraceHdrPtr, event, (ClientData)&ioRec);    \
  119.     }
  120.  
  121. #ifdef notdef
  122. #define FSUTIL_TRACE_NAME(event, pathName) \
  123.     if (fsutil_Tracing) {                            \
  124.     Trace_Insert(fsutil_TraceHdrPtr, event, (ClientData)pathName);    \
  125.     }
  126. #endif notdef
  127. #define FSUTIL_TRACE_NAME(event, pathName)
  128.  
  129. #define FSUTIL_TRACE_HANDLE(event, hdrPtr) \
  130.     if (fsutil_Tracing &&                            \
  131.     (fsutil_TracedFile < 0 || fsutil_TracedFile == hdrPtr->fileID.minor)) {    \
  132.     Fsutil_TraceHdrRec hdrRec;                        \
  133.     hdrRec.fileID = hdrPtr->fileID;                    \
  134.     hdrRec.refCount = hdrPtr->refCount;                \
  135.     if (hdrPtr->fileID.type == FSIO_LCL_FILE_STREAM) {        \
  136.         hdrRec.numBlocks = ((Fsio_FileIOHandle *)hdrPtr)->cacheInfo.blocksInCache; \
  137.     } else {                            \
  138.         hdrRec.numBlocks = -1;                    \
  139.     }                                \
  140.     Trace_Insert(fsutil_TraceHdrPtr, event, (ClientData)&hdrRec);\
  141.     }
  142.  
  143. #define FSUTIL_TRACE_BLOCK(event, blockPtr) \
  144.     if (fsutil_Tracing &&                            \
  145.     (fsutil_TracedFile < 0 ||                        \
  146.      fsutil_TracedFile == (blockPtr)->cacheInfoPtr->hdrPtr->fileID.minor)) { \
  147.     Fsutil_TraceBlockRec blockRec;                    \
  148.     blockRec.fileID = (blockPtr)->cacheInfoPtr->hdrPtr->fileID;    \
  149.     blockRec.blockNum = (blockPtr)->blockNum;            \
  150.     blockRec.flags    = (blockPtr)->flags;                \
  151.     Trace_Insert(fsutil_TraceHdrPtr, event, (ClientData)&blockRec);\
  152.     }
  153.  
  154. #define    FSUTIL_TRACE_READ_AHEAD(event, blockNum) \
  155.     if (fsutil_Tracing || fscache_RATracing) { \
  156.     Trace_Insert(fsutil_TraceHdrPtr, event, (ClientData)blockNum); \
  157.     }
  158.  
  159. #else
  160. /*
  161.  * Compiling with -DCLEAN will zap the if statement and procedure
  162.  * call defined by the above macros
  163.  */
  164.  
  165. #define FSUTIL_TRACE(event)
  166. #define FSUTIL_TRACE_IO(event, zfileID, zoffset, znumBytes)
  167. #define FSUTIL_TRACE_NAME(event, pathName)
  168. #define FSUTIL_TRACE_HANDLE(event, handlePtr)
  169. #define    FSUTIL_TRACE_READ_AHEAD(event, blockNum)
  170. #define FSUTIL_TRACE_BLOCK(event, blockPtr)
  171.  
  172. #endif not CLEAN
  173.  
  174. #endif _FSTRACE
  175.